package com.aspose.cells;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;

class zab {
   private byte[] b;
   private int c;
   private int d;
   private ActiveXControl e;
   private static final com.aspose.cells.b.c.a.za f = new com.aspose.cells.b.c.a.za(new String[]{"persistPropertyBag", "persistStorage", "persistStream", "persistStreamInit"});

   static String a(byte[] var0, int[] var1, int var2, int var3) {
      boolean var4 = ((long)var3 & 2147483648L) != 0L;
      int var5 = var3 & Integer.MAX_VALUE;
      String var6 = zco.a(var0, var1[0], var4, var5);
      var1[0] += var5 + (var4 ? 0 : var5);
      var1[0] += zad.a(var1[0] - var2, 4);
      return var6;
   }

   static ActiveXControl a(UnknownControl var0, Shape var1) throws Exception {
      byte[] var2 = var0.getData();
      byte[] var3 = new byte[16];
      System.arraycopy(var2, 0, var3, 0, 16);
      int var4 = zad.a(var3);
      ActiveXControl var5 = ActiveXControlBase.a(var4, var0, var1);
      var5.c = var3;
      return var5;
   }

   static void a(zpf var0, Shape var1, Workbook var2) throws Exception {
      String var3 = var0.c;
      if (var3 != null && var2.b != null && var2.b.b != null) {
         com.aspose.cells.a.f.zi var4 = var2.b.b.b;
         String var5 = zase.aD(var3);
         zcfw var6 = zasr.a(var4, var5, true);
         if (var6 == null) {
            return;
         }

         var6.j();
         if ("ocx".equals(var6.p())) {
            String var7 = var6.a("id");
            String var8 = var6.a("persistence");
            byte var9 = 3;
            if (var8 == null) {
               if (zbpt.a(var7)) {
                  var9 = 0;
               } else {
                  var9 = 3;
               }
            } else {
               switch(f.a(var8)) {
               case 0:
                  var9 = 0;
                  break;
               case 1:
                  var9 = 1;
                  break;
               case 2:
                  var9 = 2;
                  break;
               case 3:
                  var9 = 3;
               }
            }

            String var10 = zajh.a(var3);
            var10 = zase.aD(var10);
            var6 = zasr.a(var4, var10, true);
            ArrayList var11 = null;
            HashMap var12 = null;
            Iterator var13;
            if (var6 != null) {
               var11 = zajh.a(var6);
               var12 = new HashMap();

               zqe var14;
               String var15;
               for(var13 = var11.iterator(); var13.hasNext(); var12.put(var14.c, zaju.a(var4, var15))) {
                  var14 = (zqe)var13.next();
                  var15 = var14.e;
                  if (var15.startsWith("/")) {
                     var15 = var15.substring(1);
                  } else {
                     var15 = "xl/activeX/" + com.aspose.cells.b.a.d.zk.b(var15);
                  }
               }
            }

            var13 = null;
            byte[] var16;
            if (var9 == 3) {
               var16 = (byte[])((byte[])var12.get(var7));
            } else {
               String var17 = zase.aD(var5);
               var16 = zaju.a(var4, var17);
            }

            if (var16 != null) {
               UnknownControl var18 = new UnknownControl(var1, var16, var9);
               if (var9 != 3) {
                  var18.h = var12;
               }

               var0.i = var18;
            }
         }
      }

   }

   void b(zpf var1, Shape var2, Workbook var3) throws Exception {
      if (!var1.a()) {
         if (var1.i == null) {
            a(var1, var2, var3);
         }

         if (var1.i != null) {
            if (var1.i.getType() == 11) {
               UnknownControl var4 = (UnknownControl)var1.i;
               if (var4.g == 3) {
                  var1.i = this.b(var4, var2);
               }
            }

         }
      }
   }

   private ActiveXControl b(UnknownControl var1, Shape var2) throws Exception {
      this.e = a(var1, var2);
      if (this.e.getType() == 11) {
         return this.e;
      } else {
         byte[] var3 = var1.getData();
         this.b = var3;
         this.c = 16;
         switch(this.e.getType()) {
         case 0:
         case 7:
            this.b();
            break;
         case 1:
         case 2:
         case 3:
         case 4:
         case 6:
         case 9:
            this.c();
            break;
         case 5:
         case 10:
            this.a();
            break;
         case 8:
            this.d();
         }

         return this.e;
      }
   }

   private void a() {
      zbce var1 = (zbce)this.e.e;
      this.d = this.c + 2;
      short var2 = com.aspose.cells.b.a.zc.b(this.b, this.d);
      this.d += 2;
      boolean var3 = this.e.getType() == 10;
      this.e.d = com.aspose.cells.b.a.zc.a(this.b, this.d);
      this.d += 4;
      if (this.e.c(3)) {
         var1.b = com.aspose.cells.b.a.zc.a(this.b, this.d);
         this.d += 4;
      }

      if (this.e.c(4)) {
         var1.c = com.aspose.cells.b.a.zc.a(this.b, this.d);
         this.d += 4;
      }

      if (this.e.c(14)) {
         var1.a = com.aspose.cells.b.a.zc.a(this.b, this.d);
         this.d += 4;
      }

      if (var3 && this.e.c(5)) {
         var1.g = this.b[this.d];
         this.d += 2;
      }

      if (this.e.c(43)) {
         if (var3) {
            this.d += zad.a(this.d - this.c, 4);
         }

         var1.s = com.aspose.cells.b.a.zc.a(this.b, this.d);
         this.d += 4;
      }

      if (this.e.c(44)) {
         if (var3) {
            this.d += zad.a(this.d - this.c, 4);
         }

         var1.r = com.aspose.cells.b.a.zc.a(this.b, this.d);
         this.d += 4;
      }

      if (this.e.c(45)) {
         if (var3) {
            this.d += zad.a(this.d - this.c, 4);
         }

         var1.t = com.aspose.cells.b.a.zc.a(this.b, this.d);
         this.d += 4;
      }

      if (this.e.c(46)) {
         if (var3) {
            this.d += zad.a(this.d - this.c, 4);
         }

         var1.u = com.aspose.cells.b.a.zc.a(this.b, this.d);
         this.d += 4;
      }

      if (this.e.c(47)) {
         if (var3) {
            this.d += zad.a(this.d - this.c, 4);
         }

         var1.v = com.aspose.cells.b.a.zc.a(this.b, this.d);
         this.d += 4;
      }

      if (this.e.c(48)) {
         this.d += zad.a(this.d - this.c, 4);
         var1.w = com.aspose.cells.b.a.zc.a(this.b, this.d);
         this.d += 4;
      }

      if (var3 && this.e.c(49)) {
         this.d += zad.a(this.d - this.c, 4);
         var1.x = com.aspose.cells.b.a.zc.a(this.b, this.d);
         this.d += 4;
      }

      if (this.e.c(50)) {
         this.d += zad.a(this.d - this.c, 4);
         int var4 = com.aspose.cells.b.a.zc.a(this.b, this.d);
         var1.y = (byte)(var4 == -1 ? 3 : var4);
         this.d += 4;
      }

      if (var3 && this.e.c(51)) {
         this.d += zad.a(this.d - this.c, 2);
         var1.z = com.aspose.cells.b.a.zc.a(this.b, this.d);
         this.d += 2;
      }

      if (this.e.c(52)) {
         this.d += zad.a(this.d - this.c, 4);
         var1.A = com.aspose.cells.b.a.zc.a(this.b, this.d);
         this.d += 4;
      }

      if (this.e.c(15)) {
         this.d += zad.a(this.d - this.c, 2);
         this.d += 2;
      }

      if (!var3 && this.e.c(5)) {
         var1.g = this.b[this.d];
         ++this.d;
      }

      this.d += zad.a(this.d - this.c, 4);
      if (this.e.c(8)) {
         var1.h = com.aspose.cells.b.a.zc.a(this.b, this.d);
         this.d += 4;
         var1.i = com.aspose.cells.b.a.zc.a(this.b, this.d);
         this.d += 4;
      }

      this.c += 4 + var2;
      if (this.e.c(15)) {
         var1.k = this.e();
      }

   }

   private void b() {
      zaa var1 = this.e.e;
      this.d = this.c + 2;
      short var2 = com.aspose.cells.b.a.zc.b(this.b, this.d);
      this.d += 2;
      this.e.d = com.aspose.cells.b.a.zc.a(this.b, this.d);
      this.d += 4;
      if (this.e.c(3)) {
         var1.b = com.aspose.cells.b.a.zc.a(this.b, this.d);
         this.d += 4;
      }

      if (this.e.c(4)) {
         var1.c = com.aspose.cells.b.a.zc.a(this.b, this.d);
         this.d += 4;
      }

      if (this.e.c(14)) {
         var1.a = com.aspose.cells.b.a.zc.a(this.b, this.d);
         this.d += 4;
      }

      int var3 = 0;
      if (this.e.c(16)) {
         var3 = com.aspose.cells.b.a.zc.a(this.b, this.d);
         this.d += 4;
      }

      if (this.e.c(12)) {
         var1.l = com.aspose.cells.b.a.zc.a(this.b, this.d);
         this.d += 4;
      }

      if (this.e.c(5)) {
         var1.g = this.b[this.d];
         ++this.d;
      }

      if (this.e.getType() == 7) {
         if (this.e.c(2)) {
            this.d += zad.a(this.d - this.c, 4);
            var1.e = com.aspose.cells.b.a.zc.a(this.b, this.d);
            this.d += 4;
         }

         if (this.e.c(1)) {
            this.d += zad.a(this.d - this.c, 2);
            var1.d = this.b[this.d];
            this.d += 2;
         }

         if (this.e.c(7)) {
            this.d += zad.a(this.d - this.c, 2);
            var1.f = this.b[this.d];
            this.d += 2;
         }
      }

      if (this.e.c(9)) {
         this.d += zad.a(this.d - this.c, 2);
         this.d += 2;
      }

      if (this.e.c(0)) {
         this.d += zad.a(this.d - this.c, 2);
         var1.m = (char)(com.aspose.cells.b.a.zc.e(this.b, this.d) & '\uffff');
         this.d += 2;
      }

      if (this.e.c(15)) {
         this.d += zad.a(this.d - this.c, 2);
         this.d += 2;
      }

      this.d += zad.a(this.d - this.c, 4);
      if (this.e.c(16)) {
         int[] var4 = new int[]{this.d};
         var1.n = a(this.b, var4, this.c, var3);
         this.d = var4[0];
      }

      if (this.e.c(8)) {
         var1.h = com.aspose.cells.b.a.zc.a(this.b, this.d);
         this.d += 4;
         var1.i = com.aspose.cells.b.a.zc.a(this.b, this.d);
         this.d += 4;
      }

      this.c += 4 + var2;
      this.a(this.e);
      this.a(this.e.getFont());
   }

   private void c() {
      zanp var1 = (zanp)this.e.e;
      this.d = this.c + 2;
      short var2 = com.aspose.cells.b.a.zc.b(this.b, this.d);
      this.d += 2;
      this.e.d = com.aspose.cells.b.a.zc.a(this.b, this.d);
      this.e.a(41, (this.b[this.d + 4] & 255 & 1) != 0);
      this.d += 8;
      if (this.e.c(14)) {
         var1.a = com.aspose.cells.b.a.zc.a(this.b, this.d);
         this.d += 4;
      }

      if (this.e.c(4)) {
         var1.c = com.aspose.cells.b.a.zc.a(this.b, this.d);
         this.d += 4;
      }

      if (this.e.c(3)) {
         var1.b = com.aspose.cells.b.a.zc.a(this.b, this.d);
         this.d += 4;
      }

      if (this.e.c(25)) {
         var1.r = com.aspose.cells.b.a.zc.a(this.b, this.d);
         this.d += 4;
      }

      if (this.e.c(1)) {
         var1.d = this.b[this.d];
         ++this.d;
      }

      if (this.e.c(26)) {
         var1.s = this.b[this.d];
         ++this.d;
      }

      if (this.e.c(27)) {
         var1.t = this.b[this.d];
         ++this.d;
      }

      if (this.e.c(5)) {
         var1.g = this.b[this.d];
         ++this.d;
      }

      if (this.e.c(28)) {
         this.d += zad.a(this.d - this.c, 2);
         var1.u = (char)(com.aspose.cells.b.a.zc.e(this.b, this.d) & '\uffff');
         this.d += 2;
      }

      if (this.e.c(29)) {
         this.d += zad.a(this.d - this.c, 4);
         var1.v = com.aspose.cells.b.a.zc.a(this.b, this.d);
         this.d += 4;
      }

      if (this.e.c(30)) {
         this.d += zad.a(this.d - this.c, 2);
         var1.w = com.aspose.cells.b.a.zc.e(this.b, this.d) & '\uffff';
         this.d += 2;
      }

      if (this.e.c(31)) {
         this.d += zad.a(this.d - this.c, 2);
         var1.x = com.aspose.cells.b.a.zc.e(this.b, this.d) & '\uffff';
         this.d += 2;
      }

      if (this.e.c(32)) {
         this.d += zad.a(this.d - this.c, 2);
         var1.y = com.aspose.cells.b.a.zc.e(this.b, this.d) & '\uffff';
         this.d += 2;
      }

      if (this.e.c(33)) {
         this.d += zad.a(this.d - this.c, 2);
         var1.z = com.aspose.cells.b.a.zc.e(this.b, this.d) & '\uffff';
         this.d += 2;
      }

      if (this.e.c(34)) {
         this.d += zad.a(this.d - this.c, 2);
         var1.A = com.aspose.cells.b.a.zc.e(this.b, this.d) & '\uffff';
         this.d += 2;
      }

      if (this.e.c(35)) {
         var1.B = this.b[this.d];
         ++this.d;
      }

      if (this.e.c(36)) {
         var1.C = this.b[this.d];
         ++this.d;
      }

      if (this.e.c(37)) {
         var1.D = this.b[this.d];
         ++this.d;
      }

      if (this.e.c(38)) {
         var1.E = this.b[this.d];
         ++this.d;
      }

      if (this.e.c(39)) {
         var1.F = this.b[this.d];
         ++this.d;
      }

      int var3 = 0;
      int var4 = 0;
      int var5 = 0;
      if (this.e.c(40)) {
         this.d += zad.a(this.d - this.c, 4);
         var3 = com.aspose.cells.b.a.zc.a(this.b, this.d);
         this.d += 4;
      }

      if (this.e.c(16)) {
         this.d += zad.a(this.d - this.c, 4);
         var4 = com.aspose.cells.b.a.zc.a(this.b, this.d);
         this.d += 4;
      }

      if (this.e.c(12)) {
         this.d += zad.a(this.d - this.c, 4);
         var1.l = com.aspose.cells.b.a.zc.a(this.b, this.d);
         this.d += 4;
      }

      if (this.e.c(2)) {
         this.d += zad.a(this.d - this.c, 4);
         var1.e = com.aspose.cells.b.a.zc.a(this.b, this.d);
         this.d += 4;
      }

      if (this.e.c(7)) {
         this.d += zad.a(this.d - this.c, 4);
         var1.f = this.b[this.d];
         this.d += 4;
      }

      if (this.e.c(15)) {
         this.d += zad.a(this.d - this.c, 2);
         this.d += 2;
      }

      if (this.e.c(9)) {
         this.d += zad.a(this.d - this.c, 2);
         this.d += 2;
      }

      if (this.e.c(0)) {
         this.d += zad.a(this.d - this.c, 2);
         var1.m = (char)(com.aspose.cells.b.a.zc.e(this.b, this.d) & '\uffff');
         this.d += 2;
      }

      if (this.e.c(41)) {
         this.d += zad.a(this.d - this.c, 4);
         var5 = com.aspose.cells.b.a.zc.a(this.b, this.d);
         this.d += 4;
      }

      this.d += zad.a(this.d - this.c, 4);
      if (this.e.c(8)) {
         var1.h = com.aspose.cells.b.a.zc.a(this.b, this.d);
         this.d += 4;
         var1.i = com.aspose.cells.b.a.zc.a(this.b, this.d);
         this.d += 4;
      }

      int[] var6;
      if (this.e.c(40)) {
         var6 = new int[]{this.d};
         var1.G = a(this.b, var6, this.c, var3);
         this.d = var6[0];
      }

      if (this.e.c(16)) {
         var6 = new int[]{this.d};
         var1.n = a(this.b, var6, this.c, var4);
         this.d = var6[0];
      }

      if (this.e.c(41)) {
         var6 = new int[]{this.d};
         var1.H = a(this.b, var6, this.c, var5);
         this.d = var6[0];
      }

      this.c += 4 + var2;

      assert this.d == this.c;

      this.b(this.e);
      this.a(this.e.getFont());
      if (this.c < this.b.length && (this.e.getType() == 1 || this.e.getType() == 3)) {
         this.d = this.c + 2;
         var2 = com.aspose.cells.b.a.zc.b(this.b, this.d);
         this.d += 2;
         var1.I = com.aspose.cells.b.a.zc.a(this.b, this.d);
         this.d += 4;
         if (var1.c(42)) {
            var1.J = com.aspose.cells.b.a.zc.a(this.b, this.d);
            this.d += 4;
         }

         this.c += 4 + var2;
      }

   }

   private void d() {
      zaa var1 = this.e.e;
      this.d = this.c + 2;
      short var2 = com.aspose.cells.b.a.zc.b(this.b, this.d);
      this.d += 2;
      this.e.d = com.aspose.cells.b.a.zc.a(this.b, this.d);
      this.d += 4;
      if (this.e.c(2)) {
         var1.e = com.aspose.cells.b.a.zc.a(this.b, this.d);
         this.d += 4;
      }

      if (this.e.c(4)) {
         var1.c = com.aspose.cells.b.a.zc.a(this.b, this.d);
         this.d += 4;
      }

      if (this.e.c(1)) {
         var1.d = this.b[this.d];
         ++this.d;
      }

      if (this.e.c(5)) {
         var1.g = this.b[this.d];
         ++this.d;
      }

      if (this.e.c(6)) {
         var1.o = this.b[this.d];
         ++this.d;
      }

      if (this.e.c(7)) {
         var1.f = this.b[this.d];
         ++this.d;
      }

      if (this.e.c(9)) {
         this.d += zad.a(this.d - this.c, 2);
         this.d += 2;
      }

      if (this.e.c(10)) {
         var1.p = this.b[this.d];
         ++this.d;
      }

      if (this.e.c(14)) {
         this.d += zad.a(this.d - this.c, 4);
         var1.a = com.aspose.cells.b.a.zc.a(this.b, this.d);
         this.d += 4;
      }

      if (this.e.c(15)) {
         this.d += zad.a(this.d - this.c, 2);
         this.d += 2;
      }

      this.d += zad.a(this.d - this.c, 4);
      if (this.e.c(8)) {
         var1.h = com.aspose.cells.b.a.zc.a(this.b, this.d);
         this.d += 4;
         var1.i = com.aspose.cells.b.a.zc.a(this.b, this.d);
         this.d += 4;
      }

      this.c += 4 + var2;
      this.a(this.e);
   }

   private void a(ActiveXControl var1) {
      if (var1.c(9)) {
         var1.e.j = this.e();
      }

      if (var1.c(15)) {
         var1.e.k = this.e();
      }

   }

   private void b(ActiveXControl var1) {
      if (var1.c(15)) {
         var1.e.k = this.e();
      }

      if (var1.c(9)) {
         var1.e.j = this.e();
      }

   }

   private byte[] e() {
      this.d = this.c;
      this.d += 20;
      int var1 = com.aspose.cells.b.a.zc.a(this.b, this.d);
      this.d += 4;
      byte[] var2 = new byte[var1];
      System.arraycopy(this.b, this.d, var2, 0, var1);
      this.d += var1;
      this.c = this.d;
      return var2;
   }

   private void a(Font var1) {
      this.d = this.c + 2;
      short var2 = com.aspose.cells.b.a.zc.b(this.b, this.d);
      this.d += 2;
      int var3 = com.aspose.cells.b.a.zc.a(this.b, this.d);
      this.d += 4;
      int var4 = 0;
      if ((var3 & zad.b(17)) != 0) {
         var4 = com.aspose.cells.b.a.zc.a(this.b, this.d);
         this.d += 4;
      }

      if ((var3 & zad.b(18)) != 0) {
         int var5 = com.aspose.cells.b.a.zc.a(this.b, this.d);
         this.d += 4;
         var1.setBold((var5 & 1) != 0);
         var1.setItalic((var5 & 2) != 0);
         if ((var5 & 4) != 0) {
            var1.setUnderline(1);
         }

         var1.setStrikeout((var5 & 8) != 0);
      }

      if ((var3 & zad.b(19)) != 0) {
         var1.c(com.aspose.cells.b.a.zc.a(this.b, this.d));
         this.d += 4;
      }

      if ((var3 & zad.b(20)) != 0) {
         var1.setCharset(this.b[this.d]);
         ++this.d;
      }

      if ((var3 & zad.b(21)) != 0) {
         var1.a(this.b[this.d]);
         ++this.d;
      }

      if ((var3 & zad.b(22)) != 0) {
         this.e.e.q = this.b[this.d];
         ++this.d;
      }

      if ((var3 & zad.b(23)) != 0) {
         this.d += zad.a(this.d - this.c, 2);
         var1.b(com.aspose.cells.b.a.zc.b(this.b, this.d));
         this.d += 2;
      }

      this.d += zad.a(this.d - this.c, 4);
      if ((var3 & zad.b(17)) != 0) {
         int[] var6 = new int[]{this.d};
         var1.setName(a(this.b, var6, this.c, var4));
         this.d = var6[0];
      }

      this.c += 4 + var2;
   }
}
